//
//  MessageCenterTableViewCell.m
//  MobileOffice
//
//  Created by jjkj on 16/10/31.
//  Copyright © 2016年 liaoningjujin. All rights reserved.
//

#import "MessageCenterTableViewCell.h"

@implementation MessageCenterTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        _headImageView=[[UIImageView alloc]initWithFrame:CGRectMake(8, 8, 40, 40)];
        _headImageView.image=[UIImage imageNamed:@"k_portrait@2x"];
        _headImageView.layer.masksToBounds=YES;
        _headImageView.layer.cornerRadius=_headImageView.width/2;
        [self.contentView addSubview:_headImageView];
        
        _nameLabel=[MyControl creatLabelWithFrame:CGRectMake(_headImageView.x, _headImageView.y+_headImageView.height, 40, 20) text:@""];
        _nameLabel.textAlignment=NSTextAlignmentCenter;
        _nameLabel.font=FONT_12;
        [self.contentView addSubview:_nameLabel];
        
        _msgTitleLabel=[MyControl creatLabelWithFrame:CGRectMake(_headImageView.width+_headImageView.x+8, 8, IPHONE_WIDTH-(_headImageView.width+_headImageView.x+8), 20) text:@""];
        _msgTitleLabel.numberOfLines=0;
        _msgTitleLabel.font=FONT_15;
        [self.contentView addSubview:_msgTitleLabel];
        
        _messageLabel=[MyControl creatLabelWithFrame:CGRectMake(_headImageView.width+_headImageView.x+8, _msgTitleLabel.y+_msgTitleLabel.height+8, IPHONE_WIDTH-(_headImageView.width+_headImageView.x+8+15), 40) text:@""];
        _messageLabel.numberOfLines=0;
        _messageLabel.font=FONT_13;
        
        [self.contentView addSubview:_messageLabel];
        
        _timeLabel=[MyControl creatLabelWithFrame:CGRectMake(IPHONE_WIDTH-150-15, _messageLabel.y+_messageLabel.height, 150, 20) text:@""];
        _timeLabel.font=FONT_12;
        _timeLabel.textAlignment=NSTextAlignmentRight;
        [self.contentView addSubview:_timeLabel];
        
        _lineLabel=[[UILabel alloc]initWithFrame:CGRectMake(_messageLabel.x, 79, IPHONE_WIDTH-_messageLabel.x, 1)];
        _lineLabel.backgroundColor=BACKCOLOR_GRAY;
        [self.contentView addSubview:_lineLabel];

        _signLabel=[[UILabel alloc]initWithFrame:CGRectMake(IPHONE_WIDTH-25, 15, 10, 10)];
        _signLabel.backgroundColor=[UIColor redColor];
        _signLabel.layer.masksToBounds=YES;
        _signLabel.layer.cornerRadius=_signLabel.width/2;
        _signLabel.hidden=YES;
        [self.contentView addSubview:_signLabel];
        
        UILongPressGestureRecognizer *tapGesture= [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(tapGestureClick)];
        tapGesture.minimumPressDuration=1.0;
        [self.contentView addGestureRecognizer:tapGesture];
    }
    return self;
}

#pragma mark -手势的响应事件
- (void)tapGestureClick{
    if (_myBlock) {
        _myBlock(self.row);
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
